import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class HomeWork3 {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        Set<Integer> num=new HashSet<>();

        System.out.println("请输入1-10之间的整数，0结束");
        while(scanner.hasNextInt()) {
            int number = scanner.nextInt();
            if(number==0) {
                break;
            }
            if(number >=1&&number<10) {
                num.add(number);
            }
            else {
                System.out.println("输入的值不在1-10之间");
            }
        }
        int[] sort = new int[num.size()];
        int index = 0;
        for (int nn : num) {
            sort[index++] = nn;
        }
        for(int i=0;i<sort.length-1;i++) {
            for (int j = 0; j < sort.length - i - 1; j++) {
                if (sort[j] > sort[j + 1]) {
                    int temp = sort[j];
                    sort[j] = sort[j + 1];
                    sort[j + 1] = temp;
                }
            }
        }
        System.out.println("排好序的结果：");
        System.out.print("[");
        for (int i = 0; i < sort.length; i++) {
            System.out.print(sort[i]);
            if (i != sort.length - 1) {
                System.out.print(", ");
            }
        }
        System.out.println("]");
    }
}
